class Dog(object):
    __instance = None
    __init__flag = False

    def __new__(cls, name):
        if cls.__instance == None:
            cls.__instance = object.__new__(cls)
            return cls.__instance
        else:
            # return 上一次创建对象的引用
            return cls.__instance

    def __init__(self, name):
        if Dog.__init__flag == False:
            self.name = name
            Dog.__init__flag = True


a = Dog("旺财")
print(id(a))
print(a.name)

b = Dog("哮天犬")
print(id(b))
print(b.name)

# 423046244000
# 旺财
# 423046244000
# 旺财
